package middleware

import (
	"net/http"

	"gitee.com/liuxuezhan/ar-platform/base-common/result"
	"github.com/zeromicro/go-zero/core/logc"
	"github.com/zeromicro/go-zero/rest/httpx"
)

type ThirdPayLogMiddleware struct {
}

func NewThirdPayLogMiddleware() *ThirdPayLogMiddleware {
	return &ThirdPayLogMiddleware{}
}

func (m *ThirdPayLogMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req string
		if err := httpx.Parse(r, req); err != nil {
			result.HttpErrorResult(r.Context(), w, err)
			return
		}
		logc.Info(r.Context(), "url", r.URL.String(), "request", req)
		next(w, r)
	}

}
